$(document).ready(function() {
				var $id;
				var $balance;
				var $sumForOperation;
				var $checkedSumForOperation;

				// shows attached div that allow perform operation
				// with card
				$(".card_id").live(
						"click",
						function(event) {
							$("div#invisible_block").hide(600);
							$id = $(this).attr('id');
							$balance = $("#" + $id + ".balance").html();
							setTimeout(function() {

								// sets attributes(card id) for currency
								// operation
								$("input#hidden_id").attr("value", $id);

								// sets attributes (card id) for locking
								// operation
								$("input#hidden_id_lock").attr("value", $id);
								$("p#active_card").html($("#" + $id + ".card_id").html());
								$("div#invisible_block").show(600);
							}, 600);
						});

				// if you want to withdraw some money
				// you won't be able to get more than
				// you have on the account
				function isAllowedSumForWithdraw(n) {
					if (document.getElementById('withdraw').checked == true) {
						if ((+n) > (+$balance)) {
							return false;
						}
					}
					return true;
				}

				// checks is a string -> number
				function isNumeric(n) {
					return !isNaN(parseFloat(n)) && isFinite(n);
				}
				
				// checks is sum inputed correct. 
				// If no, locks button for sending
				$("input#enter_sum").keyup(function(event) {
									$sumForOperation = $(this).val();
									$checkedSumForOperation = $sumForOperation.replace(",", ".");
									$(this).val($checkedSumForOperation);
									if (!isNumeric(+$checkedSumForOperation)|| !isAllowedSumForWithdraw($checkedSumForOperation)) {
											document.getElementById('send_action').disabled = true;
										} else {
											document.getElementById('send_action').disabled = false;
										}
									});
				
				// if we change type of operation(withdraw or replenish)
				// we will recheck validity of sum
				$("input[type='radio']").click(function(event){
					$("input#enter_sum").trigger('keyup');
				});	
			});